package View;

import java.awt.GridLayout;
import java.util.Observable;
import java.util.Observer;

import javax.swing.JPanel;
import javax.swing.Timer;

import Control.ButtonControl;
import Model.Wereld;

public class HelicopterView extends JPanel implements Observer{
	private Wereld wereld;
	private Timer timer;
	private CompasPanel compaspanel;
	private ButtonControl buttonControl;
	//private Controlpanel controlpanel;
	
	public HelicopterView(Wereld wereld)
	{
		this.wereld = wereld;
		setLayout(new GridLayout(1,2));
		compaspanel = new CompasPanel();
		buttonControl = new ButtonControl(wereld);
		add(compaspanel);
		wereld.addObserver(this);
		add(buttonControl);
	}
	public void refreshPanel()
	{
		compaspanel.setXY(wereld.getHelicopter().getDirX(), wereld.getHelicopter().getDirY());
	}
	public void update(Observable o, Object obj) {
		if(((String)obj).equals("move"))
		{
			refreshPanel();
			revalidate();
			compaspanel.repaint();
		}
	}
}

